package sqlTestes.criarSqlDeUmaTabela;

import infra.Cenario;
import junit.framework.Assert;

import org.junit.Test;

import sql.ddl.Tabela;
import sql.ddl.coluna.ColunaComposta;

public class TabelaCom2ColunasCompostasDoMesmoTipo extends Cenario {
	Tabela minha =null;		
	Tabela agua= new Tabela("Agua",true);
	public void dadoQue() {
		aTabelaTemNomeMinhasAguas();
	}

	public void quando() {
		aTabelaEstaComAColunaCompostaAguaAguaNormalEAguaMineral();
	}

	public void entao() {
		oSqlSeraCREATETABLEMinhasAguas___();
		aTababelaTeraDuasColuna();
	}

	public void aTabelaTemNomeMinhasAguas() {
		minha = new Tabela("MinhasAguas");
	}

	public void aTabelaEstaComAColunaCompostaAguaAguaNormalEAguaMineral() {
		try {
			minha.addColuna(new ColunaComposta(agua,"aguaNormal"));
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			minha.addColuna(new ColunaComposta(agua,"aguaMineral"));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Test
	public void oSqlSeraCREATETABLEMinhasAguas___() {	
		Assert.assertEquals("CREATE TABLE MinhasAguas(fkAguaNormal INT4 NOT NULL, " +
				"fkAguaMineral INT4 NOT NULL,FOREIGN KEY(fkAguaNormal)REFERENCES Agua(pkAgua),FOREIGN KEY(fkAguaMineral)REFERENCES Agua(pkAgua))", minha.codigoSQL());		
	}
	@Test
	public void aTababelaTeraDuasColuna() {
		Assert.assertEquals(2, minha.getALLColunas().size());
	}
}